<template>
	<view class="container" v-if="isLandscape">
		游戏大厅
	</view>
	<view class="tip" v-else>
	  <text>请将设备旋转到横屏模式以查看内容</text>
	</view>
</template>

<script>
	import audioManager from '@/utils/audioManager.js';
	export default {
		data() {
			return {
				isLandscape: false
			}
		},
		//当页面加载完成触发
		mounted() {
			this.checkOrientation();
			window.addEventListener('resize', this.checkOrientation);
		},
		//当页面摧毁前触发
		beforeDestroy() {
			window.removeEventListener('resize', this.checkOrientation);
		},
		methods: {
			checkOrientation() {
			  // 检测设备方向 宽大于高
			  this.isLandscape = window.innerWidth > window.innerHeight;
			  if(this.isLandscape){
				  audioManager.playAudio('jiazai', false);
			  }else{
				  //摧毁所有音频
				  audioManager.destroyAll();
			  }
			}
		}
	}
</script>

<style>
.tip{
	width: 100%;
	height: 100vh;
	text-align: center;
	line-height: 100vh;
	font-size: 20px;
}
</style>
